import { createLogger, createStore } from 'vuex'
import createPersistedstate from 'vuex-persistedstate'
import getters from './getters'
import cart from './modules/cart'
import user from './modules/user'
import category from './modules/category'

export default createStore({
  modules: {
    user,
    cart,
    category
  },
  getters,
  // 插件配置
  plugins: [
    // 自动打印插件
    createLogger,
    // 持久化存储插件
    createPersistedstate({
      // key 名称
      key: 'erabbit-client-pc-store',
      // 需要持久化的模块
      paths: ['user', 'cart']
    })
  ]
})
